package com.demo.constant;

import java.util.HashMap;
import java.util.Map;

public class ErrorInfo {
	/**
	 * 全局相关
	 */
	public static final String ERR_SUCCESS = "0";
	public static final String ERR_FAIL = "-1";
	public static final String ERR_SYS = "8001";
	public static final String ERR_INVALID_PARAM = "8002";
	public static final String ERR_NOT_LOGIN = "8003";
	
	/**
	 * 文件相关
	 */
	public static final String ERR_IMAGE_NOT_EMPTY = "101";
	public static final String ERR_FILE_IS_NOT_IMAGE = "102";
	public static final String ERR_DEL_IMAGE_FAIL = "103";
	
	/**
	 * 用户相关
	 */
	public static final String ERR_WRONG_USERNAME_OR_PWD = "201";
	public static final String ERR_USERNAME_NOT_EMPTY = "202";
	public static final String ERR_PASSWORD_NOT_EMPTY = "203";
	public static final String ERR_NAME_NOT_EMPTY = "204";
	public static final String ERR_USERNAME_NOT_DUPLICATE = "205";
	public static final String ERR_USER_ID_NOT_EMPTY = "206";
	public static final String ERR_CODE_ERROR = "207";
	public static final String ERR_USER_DOES_NOT_EXIST = "208";
	
	/**
	 * 角色相关
	 */
	public static final String ERR_ROLENAME_NOT_EMPTY = "301";
	public static final String ERR_ID_NOT_EMPTY = "301";
	public static final String ERR_ROLENAME_NOT_DUPLICATE = "302";
	public static final String ERR_ROLE_DOES_NOT_EXIST = "303";
	
	
	@SuppressWarnings("serial")
	public static final Map<String, String> ERROR_MAP = new HashMap<String, String>(){
		{
			// 全局
			put(ERR_SUCCESS, "操作成功");
			put(ERR_FAIL, "操作失败");
			put(ERR_SYS, "系统繁忙,请重试...");
			put(ERR_INVALID_PARAM, "参数错误");
			put(ERR_NOT_LOGIN, "您未登录,请登录...");
			// 文件
			put(ERR_IMAGE_NOT_EMPTY, "上传文件不能为空!");
			put(ERR_FILE_IS_NOT_IMAGE, "请上传正确格式的图片!");
			put(ERR_DEL_IMAGE_FAIL, "图片不存在或删除失败!");
			// 用户
			put(ERR_WRONG_USERNAME_OR_PWD, "用户名或密码错误");
			put(ERR_USERNAME_NOT_EMPTY, "用户名不能为空");
			put(ERR_PASSWORD_NOT_EMPTY, "密码不能为空");
			put(ERR_NAME_NOT_EMPTY, "姓名不能为空");
			put(ERR_USERNAME_NOT_DUPLICATE, "用户名不能重复");
			put(ERR_USER_ID_NOT_EMPTY, "用户id不能为空");
			put(ERR_CODE_ERROR, "验证码错误");
			put(ERR_USER_DOES_NOT_EXIST, "用户不存在");
			// 角色
			put(ERR_ROLENAME_NOT_EMPTY, "角色名不能为空");
			put(ERR_ROLENAME_NOT_DUPLICATE, "角色名不能重复");
			put(ERR_ID_NOT_EMPTY, "角色id不能为空");
			put(ERR_ROLE_DOES_NOT_EXIST, "角色不存在");
		}
	}; 
	
	public static String getErrMsg(String errno){
		return ERROR_MAP.get(errno);
	}
}

